package org.nio;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * @author wind
 * @create 2025-01-02 9:37
 */
public class ByteBufferDemo {
    public static void main(String[] args) {
        ByteBuffer b1 = StandardCharsets.UTF_8.encode("我是中国人");
        ByteBuffer b2 = Charset.forName("utf-8").encode("我是中国人");

        ByteBufferUtil.debug(b1);
        ByteBufferUtil.debug(b2);

        CharBuffer b3 = StandardCharsets.UTF_8.decode(b1);
        System.out.println(b3.getClass());
        System.out.println(b3);
    }
}
